#!/bin/sh
#
# This is the script for generating files for a specific Dalton test job.
#
# For the .check file ksh or bash is preferred, otherwise use sh
# (and hope it is not the old Bourne shell, which will not work)
#
if [ -x /bin/ksh ]; then
   CHECK_SHELL='#!/bin/ksh'
elif [ -x /bin/bash ]; then
   CHECK_SHELL='#!/bin/bash'
else
   CHECK_SHELL='#!/bin/sh'
fi


#######################################################################
#  TEST DESCRIPTION
#######################################################################
cat > cc2_r12_aux_bh_sym_a2.info <<'%EOF%'
   cc2_r12_aux_bh_sym_a2
   -----------
   Molecule:         BH 
   Wave Function:    CC2-R12/A2/B / AhlrichsVTZ AhlrichsVTZ    
   Test Purpose:     Check CC2-R12/A2/B method with auxiliary basis 
                     and symmetry
%EOF%

#######################################################################
#  MOLECULE INPUT
#######################################################################
cat > cc2_r12_aux_bh_sym_a2.mol <<'%EOF%'
BASIS
Ahlrichs-VTZ Ahlrichs-VTZ
BH
                                                                            
    4  0 2  X  Y      0.10D-14
 1      5.    1    3    3    2    1
B        0.0000000000000     0.0000000000000     0.0000000000000
 1      1.    1
H        0.0000000000000     0.0000000000000     2.3288983083247
 2      5.0   1
B        0.0000000000000     0.0000000000000     0.0000000000000
 2      1.0   1
H        0.0000000000000     0.0000000000000     2.3288983083247
%EOF%

#######################################################################
#  DALTON INPUT
#######################################################################
cat > cc2_r12_aux_bh_sym_a2.dal <<'%EOF%'
**DALTON INPUT
.RUN WAVE FUNCTION
.DIRECT
*MOLBAS
.R12AUX
**INTEGRALS
.R12
**WAVE FUNCTION
.CC
*ORBITAL INPUT
*SCF INPUT
.THRESH
 1.0D-12
*CC INPUT
.CC2
.PRINT
 3 
.FROIMP
  1 0 0 0
  0 0 0 0
.THRENR
 1.0D-12
.MAX IT
 300
*CCEXCI
.THREXC
 1.D-10
.NCCEXCI
 4 4 4 4 
*R12 INPUT
.NO HYB
.CC2
 2B
**END OF DALTON INPUT
%EOF%
#######################################################################

 

#######################################################################

#######################################################################
#  CHECK SCRIPT
#######################################################################
echo $CHECK_SHELL >cc2_r12_aux_bh_sym_a2.check
cat >>cc2_r12_aux_bh_sym_a2.check <<'%EOF%'
log=$1

if [ `uname` = Linux ]; then
   GREP="egrep -a"
else
   GREP="egrep"
fi

if $GREP -q "not implemented for parallel calculations" $log; then
   echo "TEST ENDED AS EXPECTED"
   exit 0
fi


#             Total SCF   energy:                   -25.1195868955
#             Total MP2-R12/B energy:               -25.1924845508
#             Total CC2-R12/B energy:               -25.1928102641
# 
# 
#  +=============================================================================+
#  |  sym. | Exci.  |        CC2-R12/B  Excitation energies            | ||T1||  |
#  |(spin, |        +------------------------------------------------------------+
#  | spat) |        |     Hartree    |       eV.      |     cm-1       |    %    |
#  +=============================================================================+
#  | ^1A1  |    1   |     0.3304039  |       8.99075  |     72515.283  |  97.53  |
#  | ^1A1  |    2   |     0.3484357  |       9.48142  |     76472.796  |  97.26  |
#  | ^1A1  |    3   |     0.4599650  |      12.51628  |    100950.644  |  97.19  |
#  | ^1A1  |    4   |     0.6234864  |      16.96593  |    136839.446  |  97.87  |
#  +-----------------------------------------------------------------------------+
#  | ^1B1  |    1   |     0.1229973  |       3.34693  |     26994.794  |  98.67  |
#  | ^1B1  |    2   |     0.3609128  |       9.82094  |     79211.213  |  97.12  |
#  | ^1B1  |    3   |     0.4472515  |      12.17033  |     98160.356  |  98.10  |
#  | ^1B1  |    4   |     0.6722428  |      18.29266  |    147540.236  |  96.84  |
#  +-----------------------------------------------------------------------------+
#  | ^1B2  |    1   |     0.1229973  |       3.34693  |     26994.794  |  98.67  |
#  | ^1B2  |    2   |     0.3609128  |       9.82094  |     79211.213  |  97.12  |
#  | ^1B2  |    3   |     0.4472515  |      12.17033  |     98160.356  |  98.10  |
#  | ^1B2  |    4   |     0.6722428  |      18.29266  |    147540.236  |  96.84  |
#  +-----------------------------------------------------------------------------+
#  | ^1A2  |    1   |     0.7739121  |      21.05922  |    169854.079  |   0.00  |
#  | ^1A2  |    2   |     1.0025406  |      27.28052  |    220032.218  |   0.00  |
#  | ^1A2  |    3   |     1.0025406  |      27.28052  |    220032.218  |   0.00  |
#  | ^1A2  |    4   |     1.0837639  |      29.49072  |    237858.682  |   0.00  |
#  +=============================================================================+
# 
CRIT1=`$GREP "Total MP2-R12/B energy: *  \-25\.1924845508" $log | wc -l`
TEST[1]=`expr	$CRIT1`
CTRL[1]=2
ERROR[1]="MP2-R12/B ENERGY NOT CORRECT"
CRIT2=`$GREP "Total CC2-R12/B energy: *  \-25\.1928102641" $log | wc -l`
TEST[2]=`expr	$CRIT1`
CTRL[2]=2
ERROR[2]="CC2-R12/B ENERGY NOT CORRECT"
#
CRIT3=`$GREP "[ \|]* \^1A1[ \|]* 1[ \|]* ( |0)\.33040..[ \|]* 8\.9907.[ \|]* 72515\....[ \|]* 97\.5.[ \|]" $log | wc -l`
TEST[3]=`expr	$CRIT3`
CTRL[3]=1
ERROR[3]="CC2-R12/B 1A1 EXCITATION ENERGY NOT CORRECT"
CRIT4=`$GREP "[ \|]* \^1A1[ \|]* 2[ \|]* ( |0)\.34843..[ \|]* 9\.4814.[ \|]* 76472\....[ \|]* 97\.2.[ \|]" $log | wc -l`
TEST[4]=`expr	$CRIT3`
CTRL[4]=1
ERROR[4]="CC2-R12/B 2A1 EXCITATION ENERGY NOT CORRECT"
CRIT5=`$GREP "[ \|]* \^1A1[ \|]* 3[ \|]* ( |0)\.45996..[ \|]* 12\.5162.[ \|]* 100950\....[ \|]* 97\.1.[ \|]" $log | wc -l`
TEST[5]=`expr	$CRIT4`
CTRL[5]=1
ERROR[5]="CC2-R12/B 3A1 EXCITATION ENERGY NOT CORRECT"
CRIT6=`$GREP "[ \|]* \^1A1[ \|]* 4[ \|]* ( |0)\.62348..[ \|]* 16\.9659.[ \|]* 136839\....[ \|]* 97\.8.[ \|]" $log | wc -l`
TEST[6]=`expr	$CRIT5`
CTRL[6]=1
ERROR[6]="CC2-R12/B 4A1 EXCITATION ENERGY NOT CORRECT"
CRIT7=`$GREP "[ \|]* \^1B1[ \|]* 1[ \|]* ( |0)\.12299..[ \|]* 3\.3469.[ \|]* 26994\....[ \|]* 98\.6.[ \|]" $log | wc -l`
TEST[7]=`expr	$CRIT3`
CTRL[7]=1
ERROR[7]="CC2-R12/B 1B1 EXCITATION ENERGY NOT CORRECT"
CRIT8=`$GREP "[ \|]* \^1B1[ \|]* 2[ \|]* ( |0)\.36091..[ \|]* 9\.8209.[ \|]* 79211\....[ \|]* 97\.1.[ \|]" $log | wc -l`
TEST[8]=`expr	$CRIT3`
CTRL[8]=1
ERROR[8]="CC2-R12/B 2B1 EXCITATION ENERGY NOT CORRECT"
CRIT9=`$GREP "[ \|]* \^1B1[ \|]* 3[ \|]* ( |0)\.44725..[ \|]* 12\.1703.[ \|]* 98160\....[ \|]* 98\.1.[ \|]" $log | wc -l`
TEST[9]=`expr	$CRIT4`
CTRL[9]=1
ERROR[9]="CC2-R12/B 3B1 EXCITATION ENERGY NOT CORRECT"
CRIT10=`$GREP "[ \|]* \^1B1[ \|]* 4[ \|]* ( |0)\.67224..[ \|]* 18\.2926.[ \|]* 147540\....[ \|]* 96\.8.[ \|]" $log | wc -l`
TEST[10]=`expr	$CRIT5`
CTRL[10]=1
ERROR[10]="CC2-R12/B 4B1 EXCITATION ENERGY NOT CORRECT"
CRIT11=`$GREP "[ \|]* \^1B2[ \|]* 1[ \|]* ( |0)\.12299..[ \|]* 3\.3469.[ \|]* 26994\....[ \|]* 98\.6.[ \|]" $log | wc -l`
TEST[11]=`expr	$CRIT3`
CTRL[11]=1
ERROR[11]="CC2-R12/B 1B2 EXCITATION ENERGY NOT CORRECT"
CRIT12=`$GREP "[ \|]* \^1B2[ \|]* 2[ \|]* ( |0)\.36091..[ \|]* 9\.8209.[ \|]* 79211\....[ \|]* 97\.1.[ \|]" $log | wc -l`
TEST[12]=`expr	$CRIT3`
CTRL[12]=1
ERROR[12]="CC2-R12/B 2B2 EXCITATION ENERGY NOT CORRECT"
CRIT13=`$GREP "[ \|]* \^1B2[ \|]* 3[ \|]* ( |0)\.44725..[ \|]* 12\.1703.[ \|]* 98160\....[ \|]* 98\.1.[ \|]" $log | wc -l`
TEST[13]=`expr	$CRIT4`
CTRL[13]=1
ERROR[13]="CC2-R12/B 3B2 EXCITATION ENERGY NOT CORRECT"
CRIT14=`$GREP "[ \|]* \^1B2[ \|]* 4[ \|]* ( |0)\.67224..[ \|]* 18\.2926.[ \|]* 147540\....[ \|]* 96\.8.[ \|]" $log | wc -l`
TEST[14]=`expr	$CRIT5`
CTRL[14]=1
ERROR[14]="CC2-R12/B 4B2 EXCITATION ENERGY NOT CORRECT"
CRIT15=`$GREP "[ \|]* \^1A2[ \|]* 1[ \|]* ( |0)\.77391..[ \|]* 21\.0592.[ \|]* 169854\....[ \|]* 0\.0.[ \|]" $log | wc -l`
TEST[15]=`expr	$CRIT3`
CTRL[15]=1
ERROR[15]="CC2-R12/B 1A2 EXCITATION ENERGY NOT CORRECT"
CRIT16=`$GREP "[ \|]* \^1A2[ \|]* 2[ \|]* ( |1)\.00254..[ \|]* 27\.2805.[ \|]* 220032\....[ \|]* 0\.0.[ \|]" $log | wc -l`
TEST[16]=`expr	$CRIT3`
CTRL[16]=1
ERROR[16]="CC2-R12/B 2A2 EXCITATION ENERGY NOT CORRECT"
CRIT17=`$GREP "[ \|]* \^1A2[ \|]* 3[ \|]* ( |1)\.00254..[ \|]* 27\.2805.[ \|]* 220032\....[ \|]* 0\.0.[ \|]" $log | wc -l`
TEST[17]=`expr	$CRIT4`
CTRL[17]=1
ERROR[17]="CC2-R12/B 3A2 EXCITATION ENERGY NOT CORRECT"
CRIT18=`$GREP "[ \|]* \^1A2[ \|]* 4[ \|]* ( |1)\.08376..[ \|]* 29\.4907.[ \|]* 237858\....[ \|]* 0\.0.[ \|]" $log | wc -l`
TEST[18]=`expr	$CRIT5`
CTRL[18]=1
ERROR[18]="CC2-R12/B 4A2 EXCITATION ENERGY NOT CORRECT"

PASSED=1
for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
do 
   if [ ${TEST[i]} -ne ${CTRL[i]} ]; then
     echo "${ERROR[i]} ( test = ${TEST[i]}; control = ${CTRL[i]} ); "
     PASSED=0
   fi
done 

if [ $PASSED -eq 1 ]
then
  echo TEST ENDED PROPERLY
  exit 0
else
  echo THERE IS A PROBLEM 
  exit 1
fi

%EOF%
#######################################################################
